<template>
    <div class="join">
        <mTitle :title="title"></mTitle>
        <split></split>
        <scroll class="join-container">
            <div>
                <ul class="join-item">
                    <router-link :to="'joinText/'+item.actid" tag="li" class="join-list" v-for="(item, index) in activityList" :key="index">
                        <div class="left">
                            <img class="img" v-lazy="item.coverimg" alt="" />
                        </div>
                        <div class="middle">
                            <div class="activity-list-title">{{item.title}}</div>
                            <div class="start-wrapper">
                                <div class="start-text">
                                    <i class="icon"></i>
                                    <span class="text">开始时间</span>
                                </div>
                                <div class="start-time">
                                    <span class="start-date">{{item.startdate}}</span>
                                    <span class="start-hour">{{item.starttime}}</span>
                                </div>
                                <div class="end-text">
                                    <i class="icon"></i>
                                    <span class="text">结束时间</span>
                                </div>
                                <div class="end-time">
                                    <span class="end-date">{{item.enddate}}</span>
                                    <span class="end-hour">{{item.endtime}}</span>
                                </div>
                            </div>
                        </div>
                        <div class="right" @click.stop="joinMessageShow(item.actid)">
                            <span class="join-right-btn">互动</span>
                        </div>
                    </router-link>
                </ul>
            </div>
            <!-- 请求数据loading -->
            <!-- <div class="loading-wrapper" v-show="!activityList.length">
                <loading></loading>
            </div> -->
        </scroll>
        <div class="no-join" v-show="!activityList.length">
            <span class="text">暂未参加任何活动</span>
        </div>
        <router-view></router-view> 
    </div>
</template>

<script>
    import axios from 'axios'
    import mTitle from 'base/title/title'
    import Scroll from 'base/scroll/scroll'
    import Loading from 'base/loading/loading'
    import Split from 'base/split/split'

    export default {
        data () {
            return {
                title: "我参加的活动",
                activityList: [] 
            }
        },
        methods: {
            joinMessageShow (index) {
                this.$router.push({
                    path: '/joinMessage/'+ index
                })
            }, 
            getActivityInfo () {
                axios.post('/api/index.php?g=Api&m=Ucenter&a=myactivelist', {
                    openid: localStorage.getItem("openid"),
                    mid: localStorage.getItem("memberid"),
                }).then((res) => {
                    if (res.data.rescode=='0000') {
                        this.activityList = res.data.data
                    }
                }).catch(function (error) {

                })
            }
        },
        components: {mTitle,Scroll,Loading,Split},
        created () {
            this.getActivityInfo()
        }
    }
</script>

<style lang="stylus" scoped>
    @import '~common/stylus/mixins.styl'
    
    .join
        width: 100%
        height: 100%
        position: relative
        overflow: hidden
        background: #fff
        .no-join
            position: absolute
            width: 100%
            top: 50%
            -webkit-transform: translateY(-50%)
            transform: translateY(-50%)
            z-index: 9
            text-align: center
            left: 0
            right: 0
            .text
                font-size: 18px
                color: #0094d3
        .join-container
            position: absolute
            top: 60px
            bottom: 0px
            width: 100%
            padding: 0 15px
            box-sizing: border-box
            overflow: hidden
            .loading-wrapper
                position: absolute
                width: 100%
                top: 50%
                -webkit-transform: translateY(-50%)
                transform: translateY(-50%)
                z-index: 9
            .join-item
                width: 100%
                .join-list
                    width: 100%
                    height: 120px
                    border-bottom: 1px solid #eee
                    box-sizing: border-box
                    display: flex
                    align-items: center
                    overflow: hidden
                    position: relative
                    .left
                        flex: 0 0 100px
                        width: 100px
                        margin-right: 10px
                        .img
                            width: 100px
                    .middle
                        flex: 1
                        ellipsis()
                        .activity-list-title
                            width: 100%
                            font-size: 14px
                            ellipsis()
                        .start-wrapper
                            margin-top: 6px
                            .start-text,.end-text
                                font-size: 0
                                .icon
                                    background: url('./icon1.png') no-repeat
                                    width: 9px
                                    height: 9px
                                    background-size: 100% 100%
                                    display: inline-block
                                .text
                                    font-size: 14px
                                    color: #0094d4
                                    display: inline-block
                                    margin-left: 6px
                            .start-time,.end-time
                                font-size: 0
                                margin-top: 4px
                                .start-date,.end-date
                                    font-size: 14px
                                    color: #d40000
                                .start-hour,.end-hour
                                    font-size: 14px
                                    color: #d40000
                                    margin-left: 10px
                            .end-text
                                margin-top: 4px
                                .icon
                                    background: url('./icon2.png') no-repeat
                                    background-size: 100% 100%
                                .text
                                    color: #888
                            .end-time
                                .end-date,.end-hour
                                    color: #888
                    .right
                        position: absolute
                        right: 0
                        top: 43px
                        .join-right-btn
                            width: 66px
                            height: 24px
                            background: #0094d4
                            border-radius: 20px
                            color: #fff
                            display: block
                            text-align: center
                            line-height: 24px
                            font-size: 14px
</style>